#ifndef LEVEL_H
#define LEVEL_H

#include <vector>
#include <string>

class Level;

#include "Constants.h"
#include "Configuration.h"
#include "Player.h"
#include "DefaultPhysics.h"

typedef std::vector<Level> LevelVector;

enum MatIDs {
    miBALL,  
    miTELEPORT,
    miGOAL,
    miPICKUP,
    miNUM
};

enum MatPairs {
    mpDEFAULT,
    mpBALL_BALL, 
    mpBALL_WORLD, 
    mpTELEPORT_BALL,
    mpGOAL_BALL,
    mpPICKUP_BALL,
    mpNUM
};

/*
 * Class to hold all level specific variables. Also responsible for
 * loading/unloading its level objects
 */
class Level
{
public:
    // pointer to existing scene manager
    Ogre::SceneManager *scene_manager;
    Ogre::String name;
	Ogre::String scene_file;
	Ogre::String resource_type;
	Ogre::String resource_location;
	int seconds_for_level;
	Ogre::String normal_image;
	Ogre::String hover_image;
	Ogre::String level_name;
	bool loaded;
	
	// common level resources
    std::vector<Pickup*> pickups;
    
    // ogre newt resources
    OgreNewt::World *world;
    OgreNewt::MaterialPair *default_mat_pair;
    DefaultPhysics *default_physics;
    std::vector<OgreNewt::MaterialID*> material_ids;
    std::vector<OgreNewt::MaterialPair*> material_pairs;
    
	Level();
	Level(Ogre::String n);
	void init(Ogre::ConfigFile::SettingsMultiMap *settings);
	OgreNewt::World *load(Ogre::SceneManager *, Configuration *config, std::string material);
	void unload();
	bool isLoaded() { return loaded; }
	void setMainPlayer(Player *player);
	Player *getPlayer() { return main_player; }
	
	// Lock functions
	void setUnlocked() { locked = false; }
	void setLocked()   { locked = true; }
	bool isLocked()    { return locked; }
	bool isBonus()     { return bonus; }
	
private:
    Player *main_player;
    bool locked;
    bool bonus;
    
    void initialiseOgreNewt();
};

#endif
